#pragma once


#include "Pages/EditorPageModel.h"
#include "Path/Path.h"
#include "Document/PieceTable.h"
#include "EditorTextFilePageModel.m.h"

class RTextDocument;

RCLASS(ExtraHeader= "Document/TextDocument.h")
class REditorTextFilePageModel : public REditorPageModel
{
    ROBJECT

public:
    virtual TSharedObjectPtr<REditorPageModel> ShareClone(RObject* InOwner) const override;
    virtual SPath GetFilePath() const override;
    virtual bool HasUnsavedData() const override;
    virtual void LowLevelSave() override;
    virtual bool CanUndo() const override;
    virtual bool Undo() override;
    virtual bool CanRedo() const override;
    virtual bool Redo() override;
    virtual bool SupportFindAndReplaceText() override{return true;}

    static TSharedObjectPtr<REditorTextFilePageModel> Create(const SPath& InPath);



    //always a positive value when down 
    RFIELD()
    float ContentAreaYOffset = 0.f;

    //是否显示光标
    RFIELD()
    bool bIsCursorVisible = false;

    RFIELD()
    SDocumentPosition CursorPosition;

    TSharedObjectPtr<RTextDocument> GetDocument() const
    {
        return Document;
    }
protected:
    RFIELD()
    TSharedObjectPtr<RTextDocument> Document;


};
